Don't run backward past beginning of all-whitespace string.
authorrobertl <robertl>
Tue, 23 Sep 2003 15:56:08 +0000 (15:56 +0000)
committerrobertl <robertl>
Tue, 23 Sep 2003 15:56:08 +0000 (15:56 +0000)
util.c

diff --git a/util.c b/util.c
index fb5f624e1b4e3e1ecf95fc22e76cd25bcfd4ff3f..0bd965b8162128466beb8b32898722c939d7abab 100644 (file)
--- a/util.c
+++ b/util.c
@@ -237,6 +237,8 @@ pstrdup(char *src)
 void 
 rtrim(char *s)
 {
+       char *t = s;
+
        if (!s || !*s) {
                return;
        }
@@ -246,7 +248,7 @@ rtrim(char *s)
        }
 
        s--;
-       while (isspace (*s)) {
+       while ((s >= t) && isspace (*s)) {
                *s = 0;
                s--;
        }